jQuery(() => {
    layui.form.render('select')

    $("#btnSave").on("click", () => {
        let myUrl = apiurl + "/sys/user"

        let usr = $("#username").val();
        let pass = $("#password").val();
        let acttype = $("#acttype").val();

        let formData = new FormData();

        formData.append("username", usr);
        formData.append("password", pass);
        formData.append("acttype", acttype);

        $.ajax({
            url: apiurl + '/sys/user',
            type: 'POST',
            cache: false,
            data: formData,
            processData: false,
            contentType: false
        }).done(function (res) {
            layui.use('table', function(){
                var table = layui.table;
                
                table.render({
                  elem: '#test'
                  ,cols: [[
                    {field: 'id', title: 'ID', width: 80, sort: false},
                    {field: 'username', title: '用户名'},
                    {field: 'typename', title: '类型', width: 120},
                    {field: 'flagname', title: '标志', width: 120}
                  ]]
                  ,data: [res]
                  ,even: true
                });
              });
        })
    })
})